﻿using System.Collections;
using VitCode.Castle.Entities;

namespace AMS.Core.Entities
{
    public class Site : BaseEntity
    {
        protected string m_Address;
        protected Area m_Area;
        protected string m_Code;
        protected UserGroup m_Department;
        protected string m_Name;
        protected string m_TypeName;

        /// <summary>
        /// 名称
        /// </summary>
        public virtual string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        /// <summary>
        /// 编码
        /// </summary>
        public virtual string Code
        {
            get { return m_Code; }
            set { m_Code = value; }
        }

        /// <summary>
        /// 地址
        /// </summary>
        public virtual string Address
        {
            get { return m_Address; }
            set { m_Address = value; }
        }

        /// <summary>
        /// 所属区域
        /// </summary>
        public virtual Area Area
        {
            get { return m_Area; }
            set { m_Area = value; }
        }

        /// <summary>
        /// 类型名称
        /// </summary>
        public virtual string TypeName
        {
            get { return m_TypeName; }
            set { m_TypeName = value; }
        }

        /// <summary>
        /// 所属部门
        /// </summary>
        public UserGroup Department
        {
            get { return m_Department; }
            set { m_Department = value; }
        }


        /// <summary>
        /// 重写Equals方法
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, this))
                return true;
            if (obj == null)
                return false;
            var sObj = obj as Site;
            return sObj != null && (sObj.Id == m_Id || ((sObj.Name == m_Name) && (sObj.Code == m_Code)));
        }

        /// <summary>
        /// 重写GetHashCode方法
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 133;
            hash = 13*hash*m_Id.GetHashCode();
            return hash;
        }

        /// <summary>
        /// 重写ToString方法
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return m_Name;
        }

        public ArrayList GetRelateObjectInfo()
        {
            var al = new ArrayList();
            al.Add(new[] {typeof (AssetInfo).Name, "o.Site.Id='" + m_Id + "'", m_Name});
            al.Add(new[] {"WoCommand", "o.TargetSite.Id='" + m_Id + "' or o.OrgSite.Id='" + m_Id + "'", m_Name});
            return al;
        }
    }
}